/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.mapper;

import cn.webrx.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>Project: mybatis2021 - StudentMapper
 * <p>Powered by webrx On 2021-07-12 16:06:32
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 15
 */
public interface StudentMapper {
    //数据插入  student.getId()
    @Insert("insert into t_student value(null,#{name},#{age},#{info},#{money})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    public int save(Student student);


    public int insert(Map<String, Object> map);

    @Insert("insert into t_student value(null,#{n},#{a},#{i},#{m})")
    public int add(@Param("n") String name, @Param("a") int age, @Param("i") String info, @Param("m") Double money);

    public int append(Map<String, Object> map);

    //查询所有数据
    public List<Student> queryAll();

    @Delete("delete from t_student where id = #{id}")
    public int deleteById(int id);

    public int deleteByNameAge(@Param("name") String name,@Param("age") int age);
    public int deleteBy(Map<String,Object> map);

    //#{}  点位符 ?   ${} 字符串表达式
    //@Select("create database userdb default charset utf8")
    @Select("create database ${dbn} default charset utf8")
    public void cdb(String dbn);

    @Update("update t_student set money = money + #{money}")
    public int update(double money);

    public int updateByNameMoney(Map<String,Object> m);

    @Select("select * from t_student where id=#{id}")
    public Student queryById(int id);
    public int updateByStudent(Student student);

    //@Select("select count(*) from ${tn}")
    public int count(String tn);
    public int count();

    @Select("select count(*) c,max(age) m,avg(age) a from t_student")
    public Map<String,Object> mycount();

    @Select("select name from t_student where id = #{id}")
    public String queryBys(int id);

    @Select("select name from t_student order by id desc")
    public List<String> showNames();

    @Select("select id,name from t_student order by id desc")
    public List<Map<String,Object>> shows();

    @Select("select id,name from t_student order by id desc")
    public List<cn.webrx.vo.Student> shows2();

    @Select("show databases")
    public Set<String> dbs();

    //@Select("show tables")
    public List<String> tbs();
    //@Select("show tables in ${dbname}")
    public List<String> tbs(String dbname);



}
